package com.fr.chart.core.glyph;

import com.fr.base.core.GraphHelper;
import com.fr.base.core.json.JSONException;
import com.fr.base.core.json.JSONObject;
import com.fr.base.xml.XMLPrintWriter;
import com.fr.base.xml.XMLableReader;
import com.fr.chart.Title;
import com.fr.chart.axis.Axis;
import com.fr.chart.axis.CategoryAxis;
import com.fr.chart.axis.TextAttr;
import com.fr.chart.axis.ValueAxis;
import com.fr.chart.base.equals.Equals;
import com.fr.chart.core.ChartUtils;
import java.awt.BasicStroke;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Shape;
import java.awt.Stroke;
import java.awt.geom.Dimension2D;
import java.awt.geom.GeneralPath;
import java.awt.geom.Line2D;
import java.awt.geom.Line2D.Double;
import java.awt.geom.Point2D;
import java.awt.geom.Point2D.Double;
import java.awt.geom.Rectangle2D;
import java.awt.geom.Rectangle2D.Double;
import java.math.BigDecimal;
import java.text.Format;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;

public abstract class AxisGlyph extends SoloGlyph
{
  private static final long serialVersionUID = -1928073768268210599L;
  private TextGlyph titleGlyph = null;
  protected transient Point2D originPoint;
  protected transient double unitLength;
  protected transient double tickLength;
  protected transient double smallTickLength;
  protected transient double axisLength;
  protected transient double axisGridLength;
  protected transient Rectangle2D bounds;
  protected transient double axisLabelWidth = 8.0D;
  protected double minValue = 0.0D;
  protected double maxValue = 0.0D;

  public AxisGlyph()
  {
  }

  public AxisGlyph(Axis paramAxis)
  {
    setAxis(paramAxis);
    if (paramAxis.getTitle() != null)
      setTitleGlyph(paramAxis.getTitle().createGlyph());
  }

  public void dealPlotBoundsWithAxisLabel(Rectangle2D paramRectangle2D)
  {
    Object localObject;
    double d1 = getMaxLabelWidth();
    if (d1 > 0.0D)
    {
      d1 += 4 + getAxis().getTickLength() / 2;
      setAxisLabelWidth(d1);
    }
    if (this.titleGlyph != null)
    {
      TextAttr localTextAttr = this.titleGlyph.getTextAttr();
      String str = this.titleGlyph.getText();
      localObject = TextGlyph.calculateTextDimension(str, localTextAttr);
    }
    else
    {
      localObject = new Dimension(0, 0);
    }
    double d2 = paramRectangle2D.getX();
    double d3 = paramRectangle2D.getY();
    int i = getAxis().getAxisLabelPosition();
    switch (getAxis().getPosition())
    {
    case 2:
      if (i == 2)
      {
        paramRectangle2D.setRect(d2, d3, paramRectangle2D.getWidth() - d1 - ((Dimension2D)localObject).getWidth() - 4.0D, paramRectangle2D.getHeight());
        return;
      }
      paramRectangle2D.setRect(d2 + d1 + ((Dimension2D)localObject).getWidth() + 4.0D, d3, paramRectangle2D.getWidth() - d1 - ((Dimension2D)localObject).getWidth() - 4.0D, paramRectangle2D.getHeight());
      break;
    case 3:
      if (i == 2)
      {
        paramRectangle2D.setRect(d2, d3 + d1 + ((Dimension2D)localObject).getHeight() + 4.0D, paramRectangle2D.getWidth(), paramRectangle2D.getHeight() - d1 - ((Dimension2D)localObject).getHeight() - 4.0D);
        return;
      }
      paramRectangle2D.setRect(d2, d3, paramRectangle2D.getWidth(), paramRectangle2D.getHeight() - d1 - ((Dimension2D)localObject).getHeight() - 4.0D);
      break;
    case 4:
      if (i == 1)
      {
        paramRectangle2D.setRect(d2 + d1 + ((Dimension2D)localObject).getWidth() + 4.0D, d3, paramRectangle2D.getWidth() - d1 - ((Dimension2D)localObject).getWidth() - 4.0D, paramRectangle2D.getHeight());
        return;
      }
      paramRectangle2D.setRect(d2, d3, paramRectangle2D.getWidth() - d1 - ((Dimension2D)localObject).getWidth() - 4.0D, paramRectangle2D.getHeight());
      break;
    default:
      if (i == 1)
      {
        paramRectangle2D.setRect(d2, d3, paramRectangle2D.getWidth(), paramRectangle2D.getHeight() - d1 - ((Dimension2D)localObject).getHeight() - 4.0D);
        return;
      }
      paramRectangle2D.setRect(d2, d3 + d1 + ((Dimension2D)localObject).getHeight() + 4.0D, paramRectangle2D.getWidth(), paramRectangle2D.getHeight() - d1 - ((Dimension2D)localObject).getHeight() - 4.0D);
    }
  }

  public void calculateAxisGlyph(Rectangle2D paramRectangle2D)
  {
    init(paramRectangle2D);
    calculateAxisLengthUnit();
  }

  public void init(Rectangle2D paramRectangle2D)
  {
    double d1;
    double d2;
    Point2D.Double localDouble = null;
    Rectangle2D.Double localDouble1 = null;
    int i = getAxis().getAxisLabelPosition();
    switch (getAxis().getPosition())
    {
    case 2:
      d1 = paramRectangle2D.getHeight();
      d2 = paramRectangle2D.getWidth();
      if (i == 2)
      {
        localDouble1 = new Rectangle2D.Double(paramRectangle2D.getWidth(), 0.0D, this.axisLabelWidth, paramRectangle2D.getHeight());
        localDouble = new Point2D.Double(-paramRectangle2D.getWidth(), paramRectangle2D.getHeight());
      }
      else
      {
        localDouble1 = new Rectangle2D.Double(-this.axisLabelWidth, 0.0D, this.axisLabelWidth, paramRectangle2D.getHeight());
        localDouble = new Point2D.Double(this.axisLabelWidth, paramRectangle2D.getHeight());
      }
      break;
    case 3:
      d1 = paramRectangle2D.getWidth();
      d2 = paramRectangle2D.getHeight();
      if (i == 2)
      {
        localDouble1 = new Rectangle2D.Double(0.0D, -this.axisLabelWidth, paramRectangle2D.getWidth(), this.axisLabelWidth);
        localDouble = new Point2D.Double(0.0D, paramRectangle2D.getHeight() + this.axisLabelWidth);
      }
      else
      {
        localDouble1 = new Rectangle2D.Double(0.0D, paramRectangle2D.getHeight(), paramRectangle2D.getWidth(), this.axisLabelWidth);
        localDouble = new Point2D.Double(0.0D, 0.0D);
      }
      break;
    case 4:
      d1 = paramRectangle2D.getHeight();
      d2 = paramRectangle2D.getWidth();
      if (i == 1)
      {
        localDouble1 = new Rectangle2D.Double(-this.axisLabelWidth, 0.0D, this.axisLabelWidth, paramRectangle2D.getHeight());
        localDouble = new Point2D.Double(this.axisLabelWidth + paramRectangle2D.getWidth(), paramRectangle2D.getHeight());
      }
      else
      {
        localDouble1 = new Rectangle2D.Double(paramRectangle2D.getWidth(), 0.0D, this.axisLabelWidth, paramRectangle2D.getHeight());
        localDouble = new Point2D.Double(0.0D, paramRectangle2D.getHeight());
      }
      break;
    default:
      d1 = paramRectangle2D.getWidth();
      d2 = paramRectangle2D.getHeight();
      if (i == 1)
      {
        localDouble1 = new Rectangle2D.Double(0.0D, paramRectangle2D.getHeight(), paramRectangle2D.getWidth(), this.axisLabelWidth);
        localDouble = new Point2D.Double(0.0D, -paramRectangle2D.getHeight());
      }
      else
      {
        localDouble1 = new Rectangle2D.Double(0.0D, -this.axisLabelWidth, paramRectangle2D.getWidth(), this.axisLabelWidth);
        localDouble = new Point2D.Double(0.0D, this.axisLabelWidth);
      }
    }
    setBounds(localDouble1);
    setOrigin(localDouble);
    setAxisLength(d1);
    setAxisGridLength(d2);
  }

  public abstract void calculateAxisLengthUnit();

  public double getMaxLabelWidth()
  {
    Object localObject1;
    Object localObject2;
    double d1 = 8.0D;
    if (this instanceof CategoryAxisGlyph)
    {
      localObject1 = (CategoryAxisGlyph)this;
      ArrayList localArrayList = ((CategoryAxisGlyph)localObject1).getCategoryLabelList();
      localObject2 = localArrayList.toArray();
      int i = 0;
      while (true)
      {
        if (i >= localObject2.length)
          break label361;
        double d4 = getAxisLabelWidth((AxisGlyph)localObject1, localObject2[i].toString());
        d1 = (d4 < d1) ? d1 : d4;
        ++i;
      }
    }
    if (this instanceof ValueAxisGlyph)
    {
      localObject1 = (ValueAxisGlyph)this;
      double d2 = ((ValueAxisGlyph)localObject1).getMinValue();
      double d3 = ((ValueAxisGlyph)localObject1).getMaxValue();
      ValueAxis localValueAxis = (ValueAxis)((ValueAxisGlyph)localObject1).getAxis();
      double d6 = 1.0D;
      if (localValueAxis.isCustomIncrement())
        d6 = localValueAxis.getIncrement();
      else
        d6 = Axis.calculateIncrement(d2, d3);
      BigDecimal localBigDecimal = new BigDecimal(d2);
      double d7 = d2;
      while (true)
      {
        if (d7 >= d3)
          break label361;
        localBigDecimal = localBigDecimal.add(new BigDecimal(d6));
        double d8 = getAxisLabelWidth((AxisGlyph)localObject1, ((ValueAxisGlyph)localObject1).value2String(localBigDecimal.doubleValue()));
        d1 = (d8 < d1) ? d1 : d8;
        d7 += d6;
      }
    }
    if (this instanceof DateAxisGlyph)
    {
      localObject1 = (DateAxisGlyph)this;
      CategoryAxis localCategoryAxis = (CategoryAxis)((DateAxisGlyph)localObject1).getAxis();
      localObject2 = ChartUtils.int2Date((int)((DateAxisGlyph)localObject1).getMinValue());
      while ((ChartUtils.date2Int((Date)localObject2) <= ((DateAxisGlyph)localObject1).getMaxValue()) && ((int)this.tickLength > 0))
      {
        Object localObject3;
        String str = "test";
        if (localCategoryAxis.getFormat() != null)
        {
          localObject3 = localCategoryAxis.getFormat();
          str = ((Format)localObject3).format(localObject2);
        }
        else
        {
          localObject3 = new SimpleDateFormat("yyyy-MM-dd");
          str = ((Format)localObject3).format(localObject2);
        }
        double d5 = getAxisLabelWidth((AxisGlyph)localObject1, str);
        d1 = (d5 < d1) ? d1 : d5;
        DateAxisGlyph.nextDate((Date)localObject2, localCategoryAxis.getMainType(), (int)this.tickLength);
      }
    }
    if (getAxis().isStagger())
      label361: d1 *= 1.5D;
    return d1;
  }

  public double getAxisLabelWidth(AxisGlyph paramAxisGlyph, String paramString)
  {
    if (paramString == null)
      return 0.0D;
    TextAttr localTextAttr = paramAxisGlyph.getAxis().getTextAttr();
    if (localTextAttr == null)
      localTextAttr = new TextAttr();
    Dimension2D localDimension2D = TextGlyph.calculateTextDimension(paramString, localTextAttr);
    if ((paramAxisGlyph.getAxis().getPosition() == 1) || (paramAxisGlyph.getAxis().getPosition() == 3))
      return localDimension2D.getHeight();
    return localDimension2D.getWidth();
  }

  public abstract void setAxis(Axis paramAxis);

  public abstract Axis getAxis();

  public abstract void axisExtends(int paramInt1, int paramInt2);

  public Point2D getOrigin()
  {
    return this.originPoint;
  }

  public void setOrigin(Point2D paramPoint2D)
  {
    this.originPoint = paramPoint2D;
  }

  public abstract double getCrossValue();

  public double getAxisLength()
  {
    return this.axisLength;
  }

  public void setAxisLength(double paramDouble)
  {
    this.axisLength = paramDouble;
  }

  public double getUnitLen()
  {
    return this.unitLength;
  }

  public double getUnit()
  {
    return this.tickLength;
  }

  public double getSmallunit()
  {
    return this.smallTickLength;
  }

  public double getAxisGridLength()
  {
    return this.axisGridLength;
  }

  public void setAxisGridLength(double paramDouble)
  {
    this.axisGridLength = paramDouble;
  }

  public void setTitleGlyph(TextGlyph paramTextGlyph)
  {
    this.titleGlyph = paramTextGlyph;
  }

  public TextGlyph getTitleGlyph()
  {
    return this.titleGlyph;
  }

  public Rectangle2D getBounds()
  {
    return this.bounds;
  }

  public void setBounds(Rectangle2D paramRectangle2D)
  {
    this.bounds = paramRectangle2D;
  }

  public void setMinValue(double paramDouble)
  {
    this.minValue = paramDouble;
  }

  public double getMinValue()
  {
    return this.minValue;
  }

  public void setMaxValue(double paramDouble)
  {
    this.maxValue = paramDouble;
  }

  public double getMaxValue()
  {
    return this.maxValue;
  }

  public Point2D getPoint2D(double paramDouble)
  {
    paramDouble -= getCrossValue();
    if (getAxis().getPosition() == 2)
      return new Point2D.Double(this.originPoint.getX(), this.originPoint.getY() - this.unitLength * paramDouble);
    if (getAxis().getPosition() == 4)
      return new Point2D.Double(this.originPoint.getX(), this.originPoint.getY() - this.unitLength * paramDouble);
    if (getAxis().getPosition() == 1)
      return new Point2D.Double(this.originPoint.getX() + this.unitLength * paramDouble, this.originPoint.getY());
    return new Point2D.Double(this.originPoint.getX() + this.unitLength * paramDouble, this.originPoint.getY());
  }

  protected Point2D getPoint2DForSelf(double paramDouble)
  {
    return getPoint2D(paramDouble);
  }

  protected Point2D getPoint2DCateAxis(double paramDouble1, double paramDouble2)
  {
    return getPoint2D(paramDouble1 + paramDouble2);
  }

  protected Line2D getTickLine(double paramDouble, int paramInt1, int paramInt2)
  {
    Point2D localPoint2D = getPoint2DForSelf(paramDouble);
    Point2D.Double localDouble1 = new Point2D.Double(localPoint2D.getX() - paramInt1 / 2.0D, localPoint2D.getY());
    Point2D.Double localDouble2 = new Point2D.Double(localPoint2D.getX() + paramInt1 / 2.0D, localPoint2D.getY());
    Point2D.Double localDouble3 = new Point2D.Double(localPoint2D.getX(), localPoint2D.getY() - paramInt1 / 2.0D);
    Point2D.Double localDouble4 = new Point2D.Double(localPoint2D.getX(), localPoint2D.getY() + paramInt1 / 2.0D);
    if (paramInt2 == 3)
    {
      if (getAxis().getPosition() == 2)
        return new Line2D.Double(localDouble1, localDouble2);
      if (getAxis().getPosition() == 4)
        return new Line2D.Double(localDouble1, localDouble2);
      if (getAxis().getPosition() == 1)
        return new Line2D.Double(localDouble3, localDouble4);
      return new Line2D.Double(localDouble3, localDouble4);
    }
    if (paramInt2 == 1)
    {
      if (getAxis().getPosition() == 2)
        return new Line2D.Double(localPoint2D, localDouble2);
      if (getAxis().getPosition() == 1)
        return new Line2D.Double(localPoint2D, localDouble4);
      if (getAxis().getPosition() == 4)
        return new Line2D.Double(localPoint2D, localDouble1);
      return new Line2D.Double(localPoint2D, localDouble3);
    }
    if (paramInt2 == 2)
    {
      if (getAxis().getPosition() == 2)
        return new Line2D.Double(localPoint2D, localDouble1);
      if (getAxis().getPosition() == 1)
        return new Line2D.Double(localPoint2D, localDouble3);
      if (getAxis().getPosition() == 4)
        return new Line2D.Double(localPoint2D, localDouble2);
      return new Line2D.Double(localPoint2D, localDouble4);
    }
    return new Line2D.Double(localPoint2D, localPoint2D);
  }

  protected void drawLabel(Graphics paramGraphics, double paramDouble1, double paramDouble2, String paramString)
  {
    Point2D localPoint2D = getPoint2DForSelf(paramDouble1 + paramDouble2);
    TextAttr localTextAttr = getAxis().getTextAttr();
    if (localTextAttr == null)
      localTextAttr = new TextAttr();
    Dimension2D localDimension2D = TextGlyph.calculateTextDimension(paramString, localTextAttr);
    Rectangle2D.Double localDouble = null;
    int i = getAxis().getPosition();
    int j = getAxis().getAxisLabelPosition();
    if (j == 0)
      return;
    double d = 4 + getAxis().getTickLength() / 2;
    if (i == 2)
      if ((j == 1) || (j == 3))
        localDouble = new Rectangle2D.Double(localPoint2D.getX() - localDimension2D.getWidth() - d, localPoint2D.getY() - localDimension2D.getHeight() / 2.0D, localDimension2D.getWidth(), localDimension2D.getHeight());
      else if (j == 2)
        localDouble = new Rectangle2D.Double(localPoint2D.getX() + getAxisGridLength(), localPoint2D.getY() - localDimension2D.getHeight() / 2.0D, localDimension2D.getWidth(), localDimension2D.getHeight());
    else if (i == 1)
      if ((j == 3) || (j == 2))
        localDouble = new Rectangle2D.Double(localPoint2D.getX() - localDimension2D.getWidth() / 2.0D, localPoint2D.getY() - localDimension2D.getHeight() - d, localDimension2D.getWidth(), localDimension2D.getHeight());
      else if (j == 1)
        localDouble = new Rectangle2D.Double(localPoint2D.getX() - localDimension2D.getWidth() / 2.0D, localPoint2D.getY() + getAxisGridLength(), localDimension2D.getWidth(), localDimension2D.getHeight());
    else if (i == 4)
      if ((j == 3) || (j == 2))
        localDouble = new Rectangle2D.Double(localPoint2D.getX() + d, localPoint2D.getY() - localDimension2D.getHeight() / 2.0D, localDimension2D.getWidth(), localDimension2D.getHeight());
      else if (j == 1)
        localDouble = new Rectangle2D.Double(localPoint2D.getX() - getAxisGridLength() - localDimension2D.getWidth(), localPoint2D.getY() - localDimension2D.getHeight() / 2.0D, localDimension2D.getWidth(), localDimension2D.getHeight());
    else if ((j == 3) || (j == 1))
      localDouble = new Rectangle2D.Double(localPoint2D.getX() - localDimension2D.getWidth() / 2.0D, localPoint2D.getY() + d, localDimension2D.getWidth(), localDimension2D.getHeight());
    else if (j == 2)
      localDouble = new Rectangle2D.Double(localPoint2D.getX() - localDimension2D.getWidth() / 2.0D, localPoint2D.getY() - getAxisGridLength() - localDimension2D.getHeight(), localDimension2D.getWidth(), localDimension2D.getHeight());
    TextGlyph.drawLabel(paramGraphics, paramString, localTextAttr, localDouble);
  }

  protected void drawBGLabel(Graphics paramGraphics, double paramDouble1, double paramDouble2, String paramString, int paramInt)
  {
    Point2D localPoint2D = getPoint2DForSelf(paramDouble1 + paramDouble2);
    TextAttr localTextAttr = getAxis().getTextAttr();
    if (localTextAttr == null)
      localTextAttr = new TextAttr();
    Dimension2D localDimension2D = TextGlyph.calculateTextDimension(paramString, localTextAttr);
    Rectangle2D.Double localDouble = null;
    int i = getAxis().getPosition();
    int j = getAxis().getAxisLabelPosition();
    if (j == 0)
      return;
    int k = (paramInt % 2 == 0) ? 1 : 0;
    if (k == 0)
    {
      drawLabel(paramGraphics, paramDouble1, paramDouble2, paramString);
      return;
    }
    if (i == 2)
      if ((j == 1) || (j == 3))
        localDouble = new Rectangle2D.Double(localPoint2D.getX() - getAxisLabelWidth(), localPoint2D.getY() - localDimension2D.getHeight() / 2.0D, localDimension2D.getWidth(), localDimension2D.getHeight());
      else if (j == 2)
        localDouble = new Rectangle2D.Double(localPoint2D.getX() + getAxisGridLength() + getAxisLabelWidth() - localDimension2D.getWidth(), localPoint2D.getY() - localDimension2D.getHeight() / 2.0D, localDimension2D.getWidth(), localDimension2D.getHeight());
    else if (i == 1)
      if ((j == 3) || (j == 2))
        localDouble = new Rectangle2D.Double(localPoint2D.getX() - localDimension2D.getWidth() / 2.0D, localPoint2D.getY() - localDimension2D.getHeight(), localDimension2D.getWidth(), localDimension2D.getHeight());
      else if (j == 1)
        localDouble = new Rectangle2D.Double(localPoint2D.getX() - localDimension2D.getWidth() / 2.0D, localPoint2D.getY() + getAxisGridLength() + getAxisLabelWidth() - localDimension2D.getHeight(), localDimension2D.getWidth(), localDimension2D.getHeight());
    else if (i == 4)
      if ((j == 3) || (j == 2))
        localDouble = new Rectangle2D.Double(localPoint2D.getX() + getAxisLabelWidth() - localDimension2D.getWidth(), localPoint2D.getY() - localDimension2D.getHeight() / 2.0D, localDimension2D.getWidth(), localDimension2D.getHeight());
      else if (j == 1)
        localDouble = new Rectangle2D.Double(localPoint2D.getX() - getAxisLabelWidth() - getAxisGridLength(), localPoint2D.getY() - localDimension2D.getHeight() / 2.0D, localDimension2D.getWidth(), localDimension2D.getHeight());
    else if ((j == 3) || (j == 1))
      localDouble = new Rectangle2D.Double(localPoint2D.getX() - localDimension2D.getWidth() / 2.0D, localPoint2D.getY() + getAxisLabelWidth() - localDimension2D.getHeight(), localDimension2D.getWidth(), localDimension2D.getHeight());
    else if (j == 2)
      localDouble = new Rectangle2D.Double(localPoint2D.getX() - localDimension2D.getWidth() / 2.0D, localPoint2D.getY() - getAxisGridLength() - getAxisLabelWidth(), localDimension2D.getWidth(), localDimension2D.getHeight());
    TextGlyph.drawLabel(paramGraphics, paramString, localTextAttr, localDouble);
  }

  protected void drawTickLine(Graphics paramGraphics, Line2D paramLine2D, BasicStroke paramBasicStroke)
  {
    Graphics2D localGraphics2D = (Graphics2D)paramGraphics;
    Stroke localStroke = localGraphics2D.getStroke();
    localGraphics2D.setStroke(paramBasicStroke);
    localGraphics2D.draw(paramLine2D);
    localGraphics2D.setStroke(localStroke);
  }

  public void draw(Graphics paramGraphics)
  {
    Graphics2D localGraphics2D = (Graphics2D)paramGraphics;
    localGraphics2D.translate(getBounds().getX(), getBounds().getY());
    drawAxisGrid(paramGraphics);
    drawAxisLine(paramGraphics);
    drawAxisTitle(paramGraphics);
    localGraphics2D.translate(-getBounds().getX(), -getBounds().getY());
  }

  protected abstract void drawAxisGrid(Graphics paramGraphics);

  protected abstract void drawAxisLine(Graphics paramGraphics);

  protected void drawAxisTitle(Graphics paramGraphics)
  {
    Graphics2D localGraphics2D = (Graphics2D)paramGraphics;
    TextGlyph localTextGlyph = getTitleGlyph();
    if (localTextGlyph != null)
    {
      Rectangle2D localRectangle2D = calculatorTitleBounds(localTextGlyph);
      localTextGlyph.setBounds(localRectangle2D);
      localTextGlyph.draw(localGraphics2D);
    }
  }

  public abstract void drawTicks(Graphics paramGraphics);

  public void drawArrow(Graphics paramGraphics, Point2D paramPoint2D1, Point2D paramPoint2D2)
  {
    if (getAxis().isArrowShow())
    {
      Point2D.Double localDouble1 = new Point2D.Double(paramPoint2D2.getX() - paramPoint2D1.getX(), paramPoint2D2.getY() - paramPoint2D1.getY());
      Point2D.Double localDouble2 = new Point2D.Double();
      double d1 = paramPoint2D1.distance(paramPoint2D2);
      double d2 = 9.0D;
      double d3 = 15.0D;
      double d4 = 7.0D;
      double d5 = 3.0D;
      localDouble2.setLocation(d2 * localDouble1.getX() / d1, d2 * localDouble1.getY() / d1);
      Point2D.Double localDouble3 = new Point2D.Double(paramPoint2D2.getX() + localDouble2.getX(), paramPoint2D2.getY() + localDouble2.getY());
      localDouble2.setLocation(d3 * localDouble1.getX() / d1, d3 * localDouble1.getY() / d1);
      Point2D.Double localDouble4 = new Point2D.Double(paramPoint2D2.getX() + localDouble2.getX(), paramPoint2D2.getY() + localDouble2.getY());
      localDouble2.setLocation(d4 * localDouble1.getX() / d1, d4 * localDouble1.getY() / d1);
      Point2D.Double localDouble5 = new Point2D.Double(paramPoint2D2.getX() + localDouble2.getX(), paramPoint2D2.getY() + localDouble2.getY());
      Point2D.Double localDouble6 = new Point2D.Double(localDouble5.getX() + localDouble1.getY() / d1 * d5, localDouble5.getY() - localDouble1.getX() / d1 * d5);
      Point2D.Double localDouble7 = new Point2D.Double(localDouble5.getX() - localDouble1.getY() / d1 * d5, localDouble5.getY() + localDouble1.getX() / d1 * d5);
      GeneralPath localGeneralPath = new GeneralPath();
      localGeneralPath.moveTo((float)localDouble3.getX(), (float)localDouble3.getY());
      localGeneralPath.lineTo((float)localDouble6.getX(), (float)localDouble6.getY());
      localGeneralPath.lineTo((float)localDouble4.getX(), (float)localDouble4.getY());
      localGeneralPath.lineTo((float)localDouble7.getX(), (float)localDouble7.getY());
      localGeneralPath.closePath();
      GraphHelper.draw(paramGraphics, new Line2D.Double(paramPoint2D2, localDouble3), getAxis().getLineStyle());
      GraphHelper.draw(paramGraphics, localGeneralPath, getAxis().getLineStyle());
      GraphHelper.fill(paramGraphics, localGeneralPath);
    }
  }

  protected Line2D[] getGridLine(double paramDouble)
  {
    Line2D.Double localDouble;
    Point2D localPoint2D = getPoint2DForSelf(paramDouble);
    if (getAxis().getPosition() == 2)
      localDouble = new Line2D.Double(localPoint2D.getX(), localPoint2D.getY(), localPoint2D.getX() + getAxisGridLength(), localPoint2D.getY());
    else if (getAxis().getPosition() == 4)
      localDouble = new Line2D.Double(localPoint2D.getX() - getAxisGridLength(), localPoint2D.getY(), localPoint2D.getX(), localPoint2D.getY());
    else if (getAxis().getPosition() == 1)
      localDouble = new Line2D.Double(localPoint2D.getX(), localPoint2D.getY() + getAxisGridLength(), localPoint2D.getX(), localPoint2D.getY());
    else
      localDouble = new Line2D.Double(localPoint2D.getX(), localPoint2D.getY() - getAxisGridLength(), localPoint2D.getX(), localPoint2D.getY());
    return new Line2D[] { localDouble };
  }

  public Shape getShape()
  {
    return getBounds();
  }

  public void setAxisLabelWidth(double paramDouble)
  {
    this.axisLabelWidth = paramDouble;
  }

  public double getAxisLabelWidth()
  {
    return this.axisLabelWidth;
  }

  public Rectangle2D calculatorTitleBounds(TextGlyph paramTextGlyph)
  {
    TextAttr localTextAttr = paramTextGlyph.getTextAttr();
    String str = paramTextGlyph.getText();
    Dimension2D localDimension2D = TextGlyph.calculateTextDimension(str, localTextAttr);
    Rectangle2D.Double localDouble = null;
    if (getAxis().getPosition() == 1)
      if (getAxis().getAxisLabelPosition() == 1)
        localDouble = new Rectangle2D.Double((this.axisLength - localDimension2D.getWidth()) / 2.0D, getAxisLabelWidth() + 4.0D, localDimension2D.getWidth(), localDimension2D.getHeight());
      else
        localDouble = new Rectangle2D.Double((this.axisLength - localDimension2D.getWidth()) / 2.0D, -4.0D - localDimension2D.getHeight(), localDimension2D.getWidth(), localDimension2D.getHeight());
    else if (getAxis().getPosition() == 2)
      if (getAxis().getAxisLabelPosition() == 2)
        localDouble = new Rectangle2D.Double(getAxisLabelWidth() + 4.0D, (this.axisLength - localDimension2D.getHeight()) / 2.0D, localDimension2D.getWidth(), localDimension2D.getHeight());
      else
        localDouble = new Rectangle2D.Double(-localDimension2D.getWidth() - 4.0D, (this.axisLength - localDimension2D.getHeight()) / 2.0D, localDimension2D.getWidth(), localDimension2D.getHeight());
    else if (getAxis().getPosition() == 3)
      if (getAxis().getAxisLabelPosition() == 2)
        localDouble = new Rectangle2D.Double((this.axisLength - localDimension2D.getWidth()) / 2.0D, -localDimension2D.getHeight() - 4.0D, localDimension2D.getWidth(), localDimension2D.getHeight());
      else
        localDouble = new Rectangle2D.Double((this.axisLength - localDimension2D.getWidth()) / 2.0D, getAxisLabelWidth() + 4.0D, localDimension2D.getWidth(), localDimension2D.getHeight());
    else if (getAxis().getPosition() == 4)
      if (getAxis().getAxisLabelPosition() == 1)
        localDouble = new Rectangle2D.Double(-localDimension2D.getWidth() - 4.0D, (this.axisLength - localDimension2D.getHeight()) / 2.0D, localDimension2D.getWidth(), localDimension2D.getHeight());
      else
        localDouble = new Rectangle2D.Double(getAxisLabelWidth() + 4.0D, (this.axisLength - localDimension2D.getHeight()) / 2.0D, localDimension2D.getWidth(), localDimension2D.getHeight());
    return localDouble;
  }

  public boolean equals(Object paramObject)
  {
    if (!(paramObject instanceof AxisGlyph))
      return false;
    AxisGlyph localAxisGlyph = (AxisGlyph)paramObject;
    if (!(Equals.equals(localAxisGlyph.titleGlyph, this.titleGlyph)))
      return false;
    if (localAxisGlyph.getMaxValue() != getMaxValue())
      return false;
    return (localAxisGlyph.getMinValue() == getMinValue());
  }

  public void readXML(XMLableReader paramXMLableReader)
  {
    if (paramXMLableReader.isChildNode())
    {
      String str1 = paramXMLableReader.getTagName();
      if ("TextGlyph".equals(str1))
      {
        this.titleGlyph = ((TextGlyph)paramXMLableReader.readXMLObject(new TextGlyph()));
      }
      else if (str1.equals("Attr"))
      {
        String str2;
        if ((str2 = paramXMLableReader.getAttr("minValue")) != null)
          setMinValue(Double.valueOf(str2).doubleValue());
        if ((str2 = paramXMLableReader.getAttr("maxValue")) != null)
          setMaxValue(Double.valueOf(str2).doubleValue());
      }
    }
  }

  public void writeXML(XMLPrintWriter paramXMLPrintWriter)
  {
    if (this.titleGlyph != null)
      this.titleGlyph.writeXML(paramXMLPrintWriter);
    paramXMLPrintWriter.startTAG("Attr").attr("minValue", getMinValue()).attr("maxValue", getMaxValue()).end();
  }

  public JSONObject toJSONObject()
    throws JSONException
  {
    JSONObject localJSONObject = super.toJSONObject();
    if (this.titleGlyph != null)
      localJSONObject.put("titleGlyph", this.titleGlyph.toJSONObject());
    localJSONObject.put("axisGridLength", this.axisGridLength);
    localJSONObject.put("axisLabelWidth", this.axisLabelWidth);
    localJSONObject.put("axisLength", this.axisLength);
    localJSONObject.put("smallTickLength", this.smallTickLength);
    localJSONObject.put("tickLength", this.tickLength);
    localJSONObject.put("unitLength", this.unitLength);
    localJSONObject.put("bounds", this.bounds);
    localJSONObject.put("originPoint", this.originPoint);
    localJSONObject.put("minValue", this.minValue);
    localJSONObject.put("maxValue", this.maxValue);
    return localJSONObject;
  }
}